package com.beiding.jsonanalyzer.analyze.query;

import com.beiding.jsonanalyzer.analyze.func.FuncBase;
import com.beiding.jsonanalyzer.analyze.func.FuncFactory;

/**
 * 非条件
 * @author 丁常磊
 * @date 2022/6/27 11:32
 */

public interface NotGrammar extends ContextGenerate {

    /**
     * 添加and连接符
     *
     * @return
     */
    default NotOperator not() {
        return new NotOperator(getQueryBuilder().addElement(Connector.AND));
    }

    /**
     * 添加and连接符,放入子条件
     *
     * @param comparator
     * @return
     */
    default ConnectGrammar not(FuncFactory<FuncBase<ComparatorResult>> comparator) {
        NodeQueryBuilder context = getQueryBuilder();
        context.addElement(new NotConditionFactory(comparator));
        return new ConnectGrammar(){
            @Override
            public NodeQueryBuilder getQueryBuilder() {
                return context;
            }
        };
    }

}
